import request from "@/utils/request";
import { downloadNew } from "@/utils/request";
import _ from 'lodash';

//shop
export function getShopList(param) {
  return request({
    url: "/car/admin/shop/pageData",
    method: "post",
    data: param,
    headers: { "Content-Type": "application/json" },
  });
}
export function editShop(param) {
  return request({
    url: param.id == 0 ? "/car/admin/shop/addShop" : '/car/admin/shop/editShop',
    method: "post",
    data: param,
    headers: { "Content-Type": "application/json" },
  });
}
export function updateShopStatus(id, flag) {
  return request({
    url: "car/admin/shop/updateShopStatus?id=" + id + "&status=" + flag,
    method: "post",
    headers: { "Content-Type": "application/json" },
  });
}

//store
export function getStoreList(param) {
  return request({
    url: "/car/admin/stock/pageData",
    method: "post",
    data: param,
    headers: { "Content-Type": "application/json" },
  });
}
export function editStore(param) {
  param.carImages = _.toString(param.carImages)
  return request({
    url: param.id == 0 ? "/car/admin/stock/addStock" : '/car/admin/stock/editStock',
    method: "post",
    data: param,
    headers: { "Content-Type": "application/json" },
  });
}
export function delStock(id) {
  return request({
    url: "/car/admin/stock/delStock?id=" + id,
    method: "post",
    headers: { "Content-Type": "application/json" },
  });
}
export function stockDetails(ids) {
  return request({
    url: "/car/admin/stock/detailData?ids=" + ids,
    method: "get",
    headers: { "Content-Type": "application/json" },
  });
}

//package
export function getPackageList(param) {
  return request({
    url: "/car/admin/package/pageData",
    method: "post",
    data: param,
    headers: { "Content-Type": "application/json" },
  });
}
export function addPackage(param) {
  param.dealerIds = _.toString(param.dealerIds)
  param.stockIds = _.toString(param.stockIds)
  return request({
    url: "car/admin/package/addPackage",
    method: "post",
    data: param,
    headers: { "Content-Type": "application/json" },
  });
}
export function delPackage(id, flag) {
  return request({
    url: "car/admin/package/delPackage?id=" + id ,
    method: "post",
    headers: { "Content-Type": "application/json" },
  });
}
export function updatePackageStatus(id, flag) {
  return request({
    url: "car/admin/package/updatePackageStatus?id=" + id + "&status=" + flag,
    method: "post",
    headers: { "Content-Type": "application/json" },
  });
}
//Auction
export function getAuctionList(param) {
  return request({
    url: "/car/admin/auction/pageData",
    method: "post",
    data: param,
    headers: { "Content-Type": "application/json" },
  });
}
export function getAuctionLogPageData(param) {
  return request({
    url: "/car/admin/auction/auctionLogPageData",
    method: "post",
    data: param,
    headers: { "Content-Type": "application/json" },
  });
}
export function editAuction(param) {
  return request({
    url: param.id == 0 ? "car/admin/auction/addAuction" : '/car/admin/auction/editAuction',
    method: "post",
    data: param,
    headers: { "Content-Type": "application/json" },
  });
}
// export function delAuction(id) {
//   return request({
//     url: "/car/admin/auction/delAuction?id=" + id ,
//     method: "post",
//     headers: { "Content-Type": "application/json" },
//   });
// }
export function getAuctionDetail(id) {
  return request({
    url: "/car/admin/auction/detailData?id=" + id ,
    method: "post",
    headers: { "Content-Type": "application/json" },
  });
}
export function updateAuctionStatus(id, flag) {
  return request({
    url: "car/admin/auction/updateAuctionStatus?id=" + id + "&status=" + flag,
    method: "post",
    headers: { "Content-Type": "application/json" },
  });
}
export function delAuction(id) {
  return request({
    url: "car/admin/auction/delAuction?id=" + id ,
    method: "post",
    headers: { "Content-Type": "application/json" },
  });
}
export function cancelDelAuction(id) {
  return request({
    url: "car/admin/auction/cancelDelAuction?id=" + id ,
    method: "post",
    headers: { "Content-Type": "application/json" },
  });
}

//base
export function upLoadPicture(formData){
  return request({
    url: 'car/admin/uploadFile',
    method: 'post',
    data: formData
  })
}

export function getCarBrand() {
  return request({
    url: "/car/rule/getCarBrand",
    method: "get",
    headers: { "Content-Type": "application/json" },
  });
}
export function getCarSeries(brandId) {
  return request({
    url: "/car/rule/getCarSeries?brandId=" + brandId,
    method: "get",
    headers: { "Content-Type": "application/json" },
  });
}
export function getCarSpec(seriesId) {
  return request({
    url: "/car/rule/getCarSpec?seriesId=" + seriesId,
    method: "get",
    headers: { "Content-Type": "application/json" },
  });
}

